<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
				xmlns:ui="http://java.sun.com/jsf/facelets"
				xmlns:h="http://java.sun.com/jsf/html"
				xmlns:a4j="http://richfaces.org/a4j"
				xmlns:rich="http://richfaces.org/rich"
				xmlns:f="http://java.sun.com/jsf/core"
				xmlns:c="http://java.sun.com/jstl/core"
				xmlns:t="http://myfaces.apache.org/tomahawk"
				template="/pages/search_template.xhtml"> 

	<ui:param name="crudBean" value="#{extratoLojaBean}" />
	
	<ui:define name="saveStateObjectsDefined">
		<t:saveState value="#{crudBean.listaEstLojas}" />
		<t:saveState value="#{crudBean.listaBandeiras}" />
		<t:saveState value="#{crudBean.listaProdutos}" />
		<t:saveState value="#{crudBean.listaContas}" />
		<t:saveState value="#{crudBean.listaExtratosLoja}" />
	</ui:define>
	
	<ui:define name="buttonItens">
	
		<!-- Painel dos botoes de pesquisa -->
		<h:panelGroup rendered="#{crudBean.searching}">
			<a4j:commandButton value="#{bundle.lbl_search}" actionListener="#{crudBean.pesquisar}" reRender="tblData"/>
			<h:outputText value=" "/>
			<h:commandButton value="#{bundle.lbl_export_planilha}" action="#{crudBean.exportExcel}" reRender="tblData"/>
			<h:panelGroup rendered="#{crudBean.reporting}">
				<h:outputText value=" "/>
				<a4j:commandButton value="#{bundle.lbl_report}" action="#{crudBean.relatorio}"/>
		    </h:panelGroup>
		</h:panelGroup>

					
		<!-- Painel dos botoes de visualizacaoo -->
		<h:panelGroup rendered="#{crudBean.viewing}">
			<h:outputText value=" "/>
			<a4j:commandButton value="#{bundle.lbl_voltar}" actionListener="#{crudBean.cancelar}" reRender="formulario, panelTitle" />
		</h:panelGroup>

		<!-- Painel dos botoes de visualizacao -->
		<h:panelGroup rendered="#{crudBean.viewingDetail}">
			<h:outputText value=" "/>
			<a4j:commandButton value="#{bundle.lbl_voltar}" actionListener="history.back()" reRender="formulario, panelTitle" />
		</h:panelGroup>
		
	</ui:define>
	
	<ui:define name="requiredFieldsMessage">
		<h:outputText value="#{bundle.todosCamposObrigatorios}" rendered="#{crudBean.searching}"/>
	</ui:define>
	
	<ui:define name="content">
		<!-- Painel de Pesquisa - Inicio -->
		<h:panelGroup id="panelGroupDePesquisa" rendered="#{crudBean.searching}">
			<f:subview id="viewBusca">
				<table>
					<tr>
						<td class="tdCor"><h:outputText value="#{bundle.lbl_periodo_pagamento}"/> *</td>
						<td class="tdBranco">
							<rich:calendar value="#{crudBean.searchObject.filtro.dataLancamentoInicial}" datePattern="dd/MM/yyyy" cellWidth="24px" cellHeight="22px" style="width:200px" showWeeksBar="false" inputSize="10" converter="dataConverter" oninputkeypress="formataData(this, event);" maxlength="10" onkeypress="soNumero(this);" enableManualInput="true"/>
							<h:outputText value=" #{bundle.lbl_ate} "/>
							<rich:calendar value="#{crudBean.searchObject.filtro.dataLancamentoFinal}" datePattern="dd/MM/yyyy" cellWidth="24px" cellHeight="22px" style="width:200px" showWeeksBar="false" inputSize="10" converter="dataConverter" oninputkeypress="formataData(this, event);" maxlength="10" onkeypress="soNumero(this);" enableManualInput="true"/>
						</td>
					</tr>
					<tr>
						<td class="tdCor" width="20%"><h:outputText value="#{bundle.lbl_conta}"/></td>
						<td class="tdBranco">
							<h:selectOneMenu value="#{crudBean.searchObject.filtro.codigoConta}" converter="simpleIndexConverter">
    							<t:selectItems var="o" itemValue="#{o.codigo}" itemLabel="#{o.bancoAgenciaConta}" value="#{crudBean.listaContas}" />
    						</h:selectOneMenu>
						</td>
					</tr>
					<tr>
						<td class="tdCor" width="20%"><h:outputText value="#{bundle.lbl_rede_adquirente}"/></td>
						<td class="tdBranco">
							<h:selectOneMenu rendered="#{crudBean.exibirListaRedesAdquirentes}" value="#{crudBean.searchObject.filtro.redeAdquirenteVo.codigo}" converter="simpleIndexConverter">
    							<t:selectItems var="o" itemValue="#{o.codigo}" itemLabel="#{o.descricao}" value="#{crudBean.listaRedeAdquirentes}" />
    						</h:selectOneMenu>
							<h:outputText rendered="#{!crudBean.exibirListaRedesAdquirentes}" value=" #{crudBean.searchObject.filtro.redeAdquirenteVo.descricao} "/>
						</td>
					</tr>
					<tr>
						<td class="tdCor" width="20%"><h:outputText value="#{bundle.lbl_loja}"/></td>
						<td class="tdBranco">
							<h:selectOneMenu rendered="#{crudBean.exibirListaLojas}" value="#{crudBean.searchObject.filtro.estLojaVo.codigo}" converter="simpleIndexConverter">
    							<t:selectItems var="o" itemValue="#{o.codigo}" itemLabel="#{o.descricao}" value="#{crudBean.listaEstLojas}" />
    						</h:selectOneMenu>
							<h:outputText rendered="#{!crudBean.exibirListaLojas }" value=" #{crudBean.searchObject.filtro.estLojaVo.descricao} "/>
						</td>
					</tr>
					<tr>
						<td class="tdCor" width="25%"><h:outputText value="#{bundle.lbl_bandeira}"/></td>
						<td class="tdBranco">
							<h:selectOneMenu value="#{crudBean.searchObject.extratoPK.bandeira}" converter="simpleIndexConverter">
    							<t:selectItems var="o" itemValue="#{o.codigo}" itemLabel="#{o.descricao}" value="#{crudBean.listaBandeiras}" />
								<a4j:support event="onchange" reRender="panelGroupDePesquisa" actionListener="#{crudBean.setarListaProdutos}"/>
    						</h:selectOneMenu>
						</td>
					</tr>
					<tr>
						<td class="tdCor" width="25%"><h:outputText value="#{bundle.lbl_produto}"/></td>
						<td class="tdBranco">
							<h:selectOneMenu value="#{crudBean.searchObject.extratoPK.produto}" converter="simpleIndexConverter">
    							<t:selectItems var="o" itemValue="#{o.codigo}" itemLabel="#{o.descricao}" value="#{crudBean.listaProdutos}" />
    						</h:selectOneMenu>
						</td>
					</tr>
					
					<tr>
						<td class="tdCor"><h:outputText value="#{bundle.lbl_tipo_lancamento}" /></td>
						<td class="tdBranco">
							<table style="width: 300px;">
     		 					<tr>
     		 						<td>
										<h:selectOneRadio value="#{crudBean.searchObject.extratoPK.tipoHistorico}">
										   <f:selectItem itemValue="0" itemLabel="#{bundle.lbl_todos}"/>   
										   <f:selectItem itemValue="1" itemLabel="#{bundle.lbl_conectividade}"/>   
										   <f:selectItem itemValue="2" itemLabel="#{bundle.lbl_ajustes}"/>   
										</h:selectOneRadio>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</f:subview>
		</h:panelGroup>
		<!-- Painel de Pesquisa - Fim -->
	</ui:define>
	
	<ui:define name="list">
		<h:panelGroup id="panelGroupDeListagem" rendered="#{crudBean.searching}">
			<f:subview id="viewListagem">
				<rich:dataTable id="tblData" value="#{crudBean.listaExtratosLoja}" binding="#{crudBean.tblData}" var="rst" rowClasses="par,impar">
					
					<rich:column style="text-align: center;" sortBy="#{rst.dataLancamento}">
						<f:facet name="header">
							<h:outputText value="#{bundle.lbl_datalancamento}" />
						</f:facet>
						<h:outputText value="#{rst.dataLancamento}"/>
					</rich:column>
					<rich:column style="text-align: left;" sortBy="#{rst.loja}">
						<f:facet name="header">
							<h:outputText value="#{bundle.lbl_loja}" />
						</f:facet>
						<h:outputText value="#{rst.loja}"/>
					</rich:column>
					<rich:column styleClass="rich-table-column-right" sortBy="#{rst.valorCredito}">
						<f:facet name="header">
							<h:outputText value="#{bundle.lbl_credito}" />
						</f:facet>
						<h:outputText value="#{rst.valorCredito}"/>
					</rich:column>
					<rich:column styleClass="rich-table-column-right" sortBy="#{rst.valorDebito}">
						<f:facet name="header">
							<h:outputText value="#{bundle.lbl_debito}" />
						</f:facet>
						<h:outputText value="#{rst.valorDebito}"/>
					</rich:column>
					<rich:column styleClass="rich-table-column-right" sortBy="#{rst.saldo}">
						<f:facet name="header">
							<h:outputText value="#{bundle.lbl_saldo}" />
						</f:facet>
						<h:outputText value="#{rst.saldo}"/>
					</rich:column>
					<rich:column style="text-align: center;">
						<f:facet name="header">
							<h:outputText value="#{bundle.lbl_detalhe}" />
						</f:facet>
						<a4j:commandLink actionListener="#{crudBean.exibirOcultarContas}" ajaxSingle="true" reRender="tblData, subTblData">
							<h:graphicImage rendered="#{!rst.exibirListaContas}" value="/imagens/adicionar.bmp" height="20" width="20" style="border: 0px;"/>
							<h:graphicImage rendered="#{rst.exibirListaContas}" value="/imagens/remover.bmp" height="20" width="20" style="border: 0px;"/>
						</a4j:commandLink>
					</rich:column>
					
					<rich:subTable id="subTblDataConta" binding="#{crudBean.subTblData}" rendered="#{rst.exibirListaContas}"
							onRowMouseOver="this.style.backgroundColor='#ffff33'"
	                        onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
							value="#{rst.listaContas}" var="rstConta">
						
						<rich:column style="text-align: left;" colspan="2" sortBy="#{rstConta.bancoAgenciaConta}">
							<f:facet name="header">
								<h:outputText value="#{bundle.lbl_conta}" />
							</f:facet>
							<h:outputText value="#{rstConta.bancoAgenciaConta}"/>
						</rich:column>
						<rich:column styleClass="rich-table-column-right" sortBy="#{rstConta.creditos}">
							<f:facet name="header">
								<h:outputText value="#{bundle.lbl_credito}" />
							</f:facet>
							<h:outputText value="#{rstConta.creditos}"/>
						</rich:column>
						<rich:column styleClass="rich-table-column-right" sortBy="#{rstConta.debitos}">
							<f:facet name="header">
								<h:outputText value="#{bundle.lbl_debito}" />
							</f:facet>
							<h:outputText value="#{rstConta.debitos}"/>
						</rich:column>
						<rich:column styleClass="rich-table-column-right" sortBy="#{rstConta.saldo}">
							<f:facet name="header">
								<h:outputText value="#{bundle.lbl_saldo}" />
							</f:facet>
							<h:outputText value="#{rstConta.saldo}"/>
						</rich:column>
						<rich:column style="text-align: center;">
							<f:facet name="header">
								<h:outputText value="#{bundle.lbl_detalhe}" />
							</f:facet>
							<a4j:commandLink actionListener="#{crudBean.exibirOcultarLancamentos}" ajaxSingle="true" reRender="tblData, subTblData">
								<h:graphicImage rendered="#{!rstConta.exibirListaLancamentos}" value="/imagens/seta_para_baixo.jpg" height="20" width="20" style="border: 0px;"/>
								<h:graphicImage rendered="#{rstConta.exibirListaLancamentos}" value="/imagens/seta_para_cima.jpg" height="20" width="20" style="border: 0px;"/>
							</a4j:commandLink>
						</rich:column>	
						
						<rich:subTable id="subTblData2" binding="#{crudBean.subTblData2}" rendered="#{rstConta.exibirListaLancamentos}"
									onRowMouseOver="this.style.backgroundColor='#33FF33'"
			                        onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
									value="#{rstConta.listaLancamentos}" var="lanc">
							
							<rich:column style="text-align: left;" colspan="3" sortBy="#{lanc.extratoPK.historicoLancamento}">
								<f:facet name="header">
									<h:outputText value="#{bundle.lbl_historico}" />
								</f:facet>
								<h:outputText value="#{lanc.extratoPK.historicoLancamento}"/>
							</rich:column>	
							<rich:column style="text-align: left;">
								<f:facet name="header">
									<h:outputText value="#{bundle.lbl_documento}" />
								</f:facet>
								<h:outputText value="0"/>
							</rich:column>	
							<rich:column styleClass="rich-table-column-right" colspan="2" sortBy="#{lanc.extratoPK.valorLancamento}">
								<f:facet name="header">
									<h:outputText value="#{bundle.lbl_valor_lancamento}" />
								</f:facet>
								<h:outputText value="#{lanc.extratoPK.valorLancamento}"/>
							</rich:column>	
						</rich:subTable>
					</rich:subTable>
				</rich:dataTable>
			</f:subview>
		</h:panelGroup>
	</ui:define>
	
</ui:composition>